<?php

class Lang
{
    const DIR = 'lang/';
    
    protected static $lang = array();
    
    public static function get($id, $area = NULL)
    {
        if (isset($lang[$area], $lang[$area][$id])) {
            return $lang[$area][$id];
        }
        if (isset($lang['main'][$id])) {
            return $lang['main'][$id];
        }
        throw new LangException(sprintf('Languageentry "%s" not found in area(%smain)', $id, $area ? $area.'/' : ''));
    }
    
    protected static function getLang($area)
    {
        if (isset(self::$lang[$area])) {
            return self::$lang[$area];
        }
        return self::loadLang($area);
    }
    
    /**
     * @todo implement with userdepended lang (i18n)
     *
     * @param string $area
     */
    protected static function loadLang($area)
    {
        
    }
}

class LangException extends PhException
{}